DIR    ?= $(shell pwd)
PREFIX ?=$(PWD)/out/third

NAME  := readline-master

HOST  ?= arm-linux
ifneq ($(findstring aarch64, $(CROSS)), )
    HOST := aarch64-linux
endif

CFLAGS :=

default: clean
	make install

clean:
	@echo "cleanning" ; rm -rf $(NAME)

unpack:
	@echo "unpacking" ; test -z $(NAME) || tar xzvf $(NAME).tar.gz

dopatch: unpack
	@# do nothing

config: dopatch
	@echo "CROSS=$(CROSS)"
	@echo "CC xxx $(CFLAGS)"
	cd $(NAME)   \
		&& ./configure\
		--prefix=$(PREFIX) \
		--host=$(HOST) \
		CC=$(CROSS)gcc \
		CROSS_COMPILE=$(CROSS)gcc CFLAGS="-fPIC -L$(PREFIX)/lib"
		
build: config
	@echo "CC xxx $(CFLAGS)"
	make -C $(NAME) everything
	
install: build
	test -z $(PREFIX) || mkdir -p $(PREFIX)
	make -C $(NAME) install

help:
	@echo "make CROSS=toolchain"
	
	
